using FireStarterModeller.BO;

namespace Firestarter.DB_DomainModel.Logic
{
    public class PropertyTypeStorer : IPropertyTypeStorer
    {
        public IDMSolution Solution { get; private set; }

        public PropertyTypeStorer(IDMSolution solution)
        {
            Solution = solution;
        }

        public DMPropertyType GetDMPropertyType(string assemblyName, string propertyTypeName)
        {
            DMPropertyType dmPropertyType = Solution.PropertyTypes.Find(type => type.AssemblyName == assemblyName && type.PropertyTypeName == propertyTypeName);
            if (dmPropertyType != null) return dmPropertyType;
            dmPropertyType = new DMPropertyType { AssemblyName = assemblyName, PropertyTypeName = propertyTypeName };
            Solution.PropertyTypes.Add(dmPropertyType);
            return dmPropertyType;
        }
    }
}